<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyButtonControl">

    <Style TargetType="{x:Type local:MyButton}">
        <Setter Property="Background" Value="Blue"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="MaxHeight" Value="35"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MyButton}">
                    <Grid Width="{TemplateBinding Width}"
                          Height="{TemplateBinding Height}"
                          ClipToBounds="True">
                        <Rectangle x:Name="rectButton"
                                   RadiusX="12"
                                   RadiusY="12"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Stretch"
                                   Stroke="{TemplateBinding Background}"
                                   StrokeThickness="4"
                                   Fill="{TemplateBinding Background}"/>

                        <Rectangle x:Name="innerRectButton"
                                   RadiusX="12"
                                   RadiusY="12"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Stretch"
                                   Stroke="{TemplateBinding Foreground}"
                                   StrokeThickness="1"
                                   Margin="2"
                                   StrokeDashArray="2"
                                   Visibility="Hidden"/>
                        
                        <DockPanel Name="myContentPresenterDockPanel" HorizontalAlignment="Center"
                                   VerticalAlignment="Center">
                            <ContentPresenter x:Name="myContentPresenter" Margin="1"  
                                                  Content="{TemplateBinding  Content}"  
                                                  TextBlock.Foreground="{TemplateBinding Foreground}" />
                        </DockPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Rectangle.Stroke" TargetName="rectButton"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                        </Trigger>

                        <Trigger Property="IsFocused" Value="true">
                            <Setter Property="Rectangle.Visibility" TargetName="innerRectButton"
                                    Value="Visible"/>
                        </Trigger>
                        
                        

                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Rectangle.Stroke" TargetName="rectButton" 
                                        Value="Transparent" />
                            <Setter Property="Rectangle.Visibility" TargetName="innerRectButton"
                                    Value="Hidden"/>
                        </Trigger>
                        
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Rectangle.Opacity" TargetName="rectButton" 
                                        Value="0.6" />
                            <!--<Setter Property="Rectangle.Stroke" TargetName="rectButton" 
                                        Value="Gray" />
                            <Setter Property="Rectangle.Fill" TargetName="rectButton" 
                                        Value="Gray" />-->
                        </Trigger>     
                        
                        
                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:MyImageButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MyImageButton}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
